<?php
/**
 * Created by PhpStorm.
 * User: kajun
 * Date: 2017/4/6
 * Time: 20:38
 */
namespace Home\Controller;
use Think\Page;
class TodayController extends HomeController{
    public function  index()
    {
        $p = I('p','1');
        $page_size = 20;
        $category = M('Category')->where(array('title'=>'今日推荐'))->field('id')->find();
        $today_id = $category['id'];
        $count = M('Document')->where(array('category_id'=>$today_id ,'status'=>1))->count();
        $page = new Page($count, $page_size);
        $list = M('Document')->page($p.','.$page_size)->where(array('category_id'=>$today_id,'status'=>1))->order('create_time desc')->select();
        $server = D('Server')->limit(1)->select();
        //        微博
        $weibo = M('Url')->find();
        $this->assign('weibo', $weibo);
        $advs = M('Advertisement')->where(array('show' => '1'))->order('create_time desc')->select();
        /** 友情链接调用**/
        $link = D('Link')->order('create_time desc')->select();
        $this->assign('link',$link);
        $this->assign('advs',$advs);
        $this->assign('server',$server);
        $this->assign('today', $list);
        $this->assign('page', $page->showFront());
        $this->display();
    }
}